{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 案例1：使用PCA进行二维数据的降维\n",
    "## 数据集：data/ex7data1.ma"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import scipy.io as sio\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(50, 2)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mat = sio.loadmat('./data/ex7data1.mat')\n",
    "X = mat['X']\n",
    "X.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAAD8CAYAAABXe05zAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAEexJREFUeJzt3V+MXOV9xvHnyWLKQoNWKtsIr+ua3CxSQ8GwQo1WQgXSOGkQssgNVVOpufFNhYgqObIrVS1XuLJUJVdVLWhEFZoqBWOpocWN5KCUSIB2WVOHGF+U4oZ1U29UttRhU1zz68WOYRnv7Jwzc/6953w/kmXv7vx5z6z8zDu/83vf44gQACAdH6t7AACAfAhuAEgMwQ0AiSG4ASAxBDcAJIbgBoDEENwAkBiCGwASQ3ADQGKuKuNBb7jhhti1a1cZDw0ArbS4uPjTiJjOcttSgnvXrl1aWFgo46EBoJVsn816W0olAJAYghsAEkNwA0BiCG4ASAzBDQCJIbgBIDGltAMCwFaOLS3r8PEzOre6pu1Tk9q/Z1Z7d8/UPaxkENwAKnVsaVkHj57S2sVLkqTl1TUdPHpKkgjvjCiVAKjU4eN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XqLUlvbfiU+ZTWg3xsBHdJeifmHpd0OiL+vO7x1MH2tO2p3r8nJX1G0uv1jqoaEXEwInZExC5JD0o6ERFfqnlYlbJ9Xe/EvHolgs9K6kyHWUT8RNKPbc/2vnWvpEKaE0q9WLDtb0n6TUk32H5L0p9ExONlPmeDzEv6PUmnejVeSfqjiPiHGsdUtRslPWF7QuuThG9HRCfb4jrqE5KeWZ/D6CpJfxMRz9U7pMo9JOnJXkfJG5K+XMSDsnISABJDqQQAEkNwA0BiCG4ASAzBDQCJIbgBIDEENwAkhuAGgMQQ3ACQmP8HJCKm+2fWOqEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X[:,0],X[:,1])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1. 对X去均值化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAD8CAYAAABjAo9vAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAEelJREFUeJzt3W+IXNd5x/Hf4/XaGSeFbZBo0MobCWpEHMtUdHBSVGjqGFZJg62IBmJKEghFGGpIIIhIFdSGEiQQhEKbNwKbvFGTFixvQuQi28jg1KCQlddEcmQFkaJWo9AoTTdJ6227kp++2F17tZ4/d+aeuefcc78fEHhXs3fOnbV+c+a5zznX3F0AgHzcFnsAAICwCHYAyAzBDgCZIdgBIDMEOwBkhmAHgMwQ7ACQGYIdADJDsANAZm6P8aSbNm3ybdu2xXhqAKitc+fO/cLdNw96XJRg37Ztm+bn52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Nble436pIoVZvY+Sc9I+vKG6sXIKgt2d3+o4EP/XtIpZRbsg87fzL4g6VOSPu4Z9qAO8ftviquS7l739VZJ1yKNBZGY2aRWQv2Eu58Mddwkauxmds+6Lx+W9EasscRgZnskfVXSw+7+ZuzxoBI/lHSPmW03szskfVbSdyOPCRUyM5P0lKSL7v71oMdOYXJoZs9I2iHpLa3s+viYu3fijqo6ZnZZ0p2S/mP1W2fd/bGIQ6qUmX1a0t9K2ixpUdJr7j4bd1TjZ2aflPQ3kiYkPe3uX4s8pEqZ2bckfUwruxv+u6Qn3P2pqIOqkJn9oaTvSzqvleyTpL909+dKHzuFYAcAhJNEKQYAEA7BDgCZIdgBIDMEOwBkhmAHgMwQ7ACQGYIdADJDsANAZv4fYcuEHO/HLJgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "X_demean = X - np.mean(X,axis=0)\n",
    "plt.scatter(X_demean[:,0],X_demean[:,1])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.计算协方差矩阵"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1.34852518, 0.86535019],\n",
       "       [0.86535019, 1.02641621]])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "C = X_demean.T@X_demean / len(X)\n",
    "C"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3.计算特征值，特征向量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "U,S,V = np.linalg.svd(C)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([2.06768062, 0.30726078])"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "S"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-0.76908153, -0.63915068],\n",
       "       [-0.63915068,  0.76908153]])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "U"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "U1 = U[:,0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4.实现降维"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "X_reduction = X_demean@U1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAa4AAAGfCAYAAAAH0zaSAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAH2xJREFUeJzt3X90VdWd9/HPl5DqVUbzONJaYq0sK1lVQDONVkqrLdaGqi0hguKPSqcqU3+PsvJU5GmtVQQbOrbrwR/FAo4dq1iBxCpPQRd0rL9gQhOlqLF0xl+htVSJWg0YYD9/XGIDJuQm99xz9j73/VrLtczl5pyvZ+H93LP39+xtzjkBABCKQUkXAABAfxBcAICgEFwAgKAQXACAoBBcAICgEFwAgKAQXACAoBBcAICgEFwAgKAMTuKkBx98sDv88MOTODUAwFPr1q37q3NuaF/vSyS4Dj/8cDU1NSVxagCAp8zs5Vzex1AhACAoBBcAICgEFwAgKAQXACAoBBcAICgEFwAgKAQXACAoBBcAICgEFwAgKAQXACAoBBcA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VhEHV1/XysymSjpd0smuiJ9p6MffKXzYa5I+0e3nQyVtSqgWpIiZlSobWvc455ZGfXxv5rjM7MhuP35d0gtJ1eI7Mxsv6TuSvu6cey/pehCs/5J0pJkNN7OPSJoi6cGEa0LgzMwkLZD0vHPu3wpyDl++rJvZEkkVknYqu3L8t51zbclW5Scz2yhpH0lv7HrpaefctxMsyUtmNlHS/5U0VFK7pBbnXHWyVfnFzE6V9GNJJZIWOudmJVySl8zsXklfVHbF89clXeecW5BoUZ4ys89L+q2k9cp+nkvStc655ZGdw5fgAgAgF94MFQIAkAuCCwAQFIILABAUggsAEBSCCwAQFIILABAUggsAEBSCCwAQlP8PBrI9f2+Oj60AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 504x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(7,7))\n",
    "plt.scatter(X_demean[:,0],X_demean[:,1])\n",
    "plt.plot([0,U1[0]],[0,U1[1]],c='r')\n",
    "plt.plot([0,U[:,1][0]],[0,U[:,1][1]],c='k')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 5.还原数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "X_restore = X_reduction.reshape(50,1)@U1.reshape(1,2) + np.mean(X,axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((50,), (2,))"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X_reduction.shape,U1.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAAD8CAYAAABXe05zAAAABHNCSVQICAgIfAhkiAAAAAlwS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kuChtz9jZLOk/S3lXRpHnRLeqOkL7v7UkkvSVoT1ZMRuCNUye9+X9K33X1D0uNJQuXr4j2S3p3wUOIwJGm4kuf9rqSzzexbyQ4pXu6+o/Jzp6TbJJ2Z7Ihis13S9infLL+nciCPBIE7IpUFuq9Leszdv5j0eOJkZv1m1lf5e1HSOyU9nuyooufuV7j7Inc/UdIHJW1y9wsTHlZszGxBZSFelTTBOZJyUVHm7s9K2mZmSyoXLZMUWSFCd1QPLElm9h1Jb5d0rJltl/Q5d/96lM+ZIkOSPiLpoUquV5L+3t1/nOCY4nK8pG+aWZfKk4NRd89daVwOvVrSbeU5i7ol3eruP012SLH6jKRvVypKnpL0iaieiJ2TAJAxpEoAIGMI3ACQMQRuAMgYAjcAZAyBGwAyhsANABlD4AaAjCFwA0DG/D9C70lWI4y6GAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X[:,0],X[:,1])\n",
    "plt.scatter(X_restore[:,0],X_restore[:,1])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
